package com.zrrd._01_servlet.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author WanJl
 * @version 1.0
 * @title RequestDemo02
 * @description
 * @create 2024/1/13 10:24
 */
@WebServlet("/requestDemo02")
public class RequestDemo02  extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取请求行的数据.....
        //获取请方式
        System.out.println(req.getMethod());
        //获取项目访问路径
        System.out.println(req.getContextPath());
        //获取url
        System.out.println(req.getRequestURL());

        //获取请求头的数据：
        System.out.println(req.getHeader("Accept"));



        //-----*重点*------ 获取请求体数据：
        req.getInputStream();
        req.getReader();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
